package cn.codeforfun.common;

import cn.codeforfun.consts.SessionConsts;
import cn.codeforfun.user.User;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpSession;

/**
 * Created by Administrator on 2017/2/15 0015.
 */
@Controller
@RequestMapping("/session")
public class SessionController {
    @RequestMapping("/getCurrentUser")
    @ResponseBody
    public User getCurrentUser(HttpSession session) {
        if (session.getAttribute(SessionConsts.USER) == null) return null;
        return (User) session.getAttribute(SessionConsts.USER);
    }
}
